package com.tarena.csmall.sentinel.demo03.service;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import com.tarena.csmall.sentinel.demo03.handler.HelloServiceBlockHandler;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @author java@tedu.cn
 * @version 1.0
 */
@Service
public class HelloService {
    @SentinelResource(
            value = "serviceHi",
            blockHandler="aaa",blockHandlerClass = HelloServiceBlockHandler.class,
            fallback = "bbb",fallbackClass = HelloServiceBlockHandler.class)
    public String sayHi(String name){
        System.out.println("进入到service的saiHi");
        String result="你好啊!"+name;
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        int a=1/0;
        return result;
    }
}
